import { reactiveHandler } from "./handlers"

const proxyCache = new WeakMap<object, object>()


function createReactiveObj<T extends object>(
  target:T, readonly:boolean, proxyHandler:ProxyHandler<T>):T {
  
  if(proxyCache.has(target)) return proxyCache.get(target) as T

  const proxy = new Proxy(target, proxyHandler)  
  
  proxyCache.set(target, proxy)

  return proxy
}

export function reactive<T extends object>(target:T):T {
  return createReactiveObj(target, false, reactiveHandler)
}

export function shallowReactive<T extends object>(target:T) {}

export function readonly<T extends object>(target:T) {}

export function shallowReadonly() {}
